home *** CD-ROM | disk | FTP | other *** search
- //: C03:Guess.cpp
- // From Thinking in C++, 2nd Edition
- // Available at http://www.BruceEckel.com
- // (c) Bruce Eckel 1999
- // Copyright notice in Copyright.txt
- // Guess a number (demonstrates "while")
- #include <iostream>
- using namespace std;
-
- int main() {
- int secret = 15;
- int guess = 0;
- // "!=" is the "not-equal" conditional:
- while(guess != secret) { // Compound statement
- cout << "guess the number: ";
- cin >> guess;
- }
- cout << "You guessed it!" << endl;
- } ///:~
-